import utils from '../../core/utils';

export default class homeVideoModel {
  code: number;
  message: string;
  ttl: number;
  data: homeFeedDataModel;
}

export class homeFeedDataModel {
  items: Array<homeDataModel>;
}

export class homeDataModel {
  banner_item: Array<bannerItem>;
  title: string;

  get getTitle() {
    if (this.title == "" && this.uri == "")
      return "你追的番剧更新啦~";
    return this.title;
  }

  cover: string;
  uri: string;
  param: string;
  card_goto: string;
  idx: string;
  three_point: threePoint;
  args: homeFeedArgs;
  rcmd_reason_style: homeFeedRcmdReasonStyle;
  desc_button: homeFeedDescButton;
  cover_left_text_1: string;
  cover_left_text_2: string;
  cover_left_icon_1: number;
  cover_left_icon_2: number;

  get left_text() {
    return `${this.iconToText(this.cover_left_icon_1)}${this.cover_left_text_1 ?? ""} ${this.iconToText(this.cover_left_icon_2)}${this.cover_left_text_2 ?? ""}`;
  }

  cover_right_text: string;
  badge: string;

  get showBadge() {
    return !utils.isEmpty(this.badge);
  }

  get showCoverText() {
    return!utils.isEmpty(this.cover_left_text_1) || !utils.isEmpty(this.cover_left_text_2) || !utils.isEmpty(this.cover_right_text);
  }

  get showRcmd() {
    return this.rcmd_reason_style != null && !utils.isEmpty(this.rcmd_reason_style.text);
  }

  private iconToText(icon: number) {
    switch (icon) {
      case 1:
      case 6:
        return "观看:";
      case 2:
        return "人气:";
      case 3:
        return "弹幕:";
      case 4:
        return "追番:";
      case 7:
        return "评论:";
      default:
        return "";
    }
  }
}

export class bannerItem {
  id: number;
  title: string;
  image: string;
  hash: string;
  request_id: string;
  server_type: number;
  resource_id: number;
  index: number;
  cm_mark: number;
}

export class threePoint{
  dislike_reasons:Array<dislikeReasons>;
}

export class dislikeReasons {
  id: number;
  name: string;
}

export class homeFeedArgs {
  up_id: string;
  up_name: string;
  rid: number;
  tid: number;
  tname: string;
  rname: string;
  aid: number;
}

export class homeFeedRcmdReasonStyle {
  text: string;
  text_color: string;
  bg_color: string;
  border_color: string;
  bg_style: number;
}

export class homeFeedDescButton {
  text: string;
}